< previous page page_147 next page >

Page 147
Second, the image is a bit-by-bit copy of whatever the form looks like on your screen. Your monitor probably has a much lower resolution than your printer does. A typical computer monitor has a resolution of 96 pixels per inch. Many printers have resolutions of 300 dots per inch. When the 96-pixels-per-inch picture is stretched to a reasonable size at 300 dots per inch, it appears rough and grainy.
Another problem with the PrintForm method is that it usually sends far more data to the printer than necessary. Suppose you have a 400-by-400 pixel form with the word ''Hello" displayed in the middle. The PrintForm method sends your printer information describing all of the form's 160,000 pixels, even though only a few contain interesting data. Sending the printer only the text "Hello," together with some information about the text's position and font characteristics, is much faster.
Some applications have more subtle problems with PrintForm. If the form contains a scrolling region, like a text box with scrollbars, PrintForm displays only the portion of the region that is visible at the time it is invoked. If the user resizes the form or if there is an unknown amount of information in the scrolling region, it may be difficult to tell if all of the information is visible.
Despite these drawbacks, the PrintForm method is simple and powerful. With a single line of code, you can print almost anything. For that reason, it is still useful, particularly in the early stages of program development. In the project's later stages, when form layouts are final, you can go back and write printing routines that take advantage of the printer's higher resolution.
High-Resolution Printing
Printer objects provide most of the same graphic properties and methods provided by forms and picture boxes. Printer objects have the properties CurrentX, CurrentY, DrawMode, DrawStyle, DrawWidth, FillColor, FillStyle, Font, FontBold, FontCount, FontItalic, FontName, FontSize, FontStrikethru, FontTransparent, FontUnderline, ForeColor, ScaleHeight, ScaleLeft, ScaleMode, ScaleTop, ScaleWidth, TwipsPerPixelX, and TwipsPerPixelY. Printer objects also provide the methods Circle, Line, PaintPicture, Print, PSet, Scale, ScaleX, ScaleY, TextHeight, and TextWidth.
Printer objects even have device contexts and support API drawing functions such as Polygon and Polyline. However, the API functions print nothing unless your program uses some Visual Basic method to print something first. If you do not want the Visual Basic method to modify the printout, use the following statement:
e10a6a0a59f035e870d90cca05b85fce.gif
Printer. Print ""
Although this statement does nothing visible, it initializes the printer so that the API functions can work properly.
Example program PolyPrnt uses the Polyline, Polygon, PolyPolyline, and PolyPolygon API functions to print several shapes. It uses Visual Basic's Line method to draw four boxes on the printout, so it does not need to print a blank string to initialize the printer.

 
< previous page page_147 next page >